package com.ruoyi.finance.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.finance.mapper.TIndustryMapper;
import com.ruoyi.finance.domain.TIndustry;
import com.ruoyi.finance.service.ITIndustryService;

/**
 * 行业表Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-02-24
 */
@Service
public class TIndustryServiceImpl implements ITIndustryService 
{
    @Autowired
    private TIndustryMapper tIndustryMapper;

    /**
     * 查询行业表
     * 
     * @param id 行业表主键
     * @return 行业表
     */
    @Override
    public TIndustry selectTIndustryById(Long id)
    {
        return tIndustryMapper.selectTIndustryById(id);
    }

    /**
     * 查询行业表列表
     * 
     * @param tIndustry 行业表
     * @return 行业表
     */
    @Override
    public List<TIndustry> selectTIndustryList(TIndustry tIndustry)
    {
        return tIndustryMapper.selectTIndustryList(tIndustry);
    }

    /**
     * 新增行业表
     * 
     * @param tIndustry 行业表
     * @return 结果
     */
    @Override
    public int insertTIndustry(TIndustry tIndustry)
    {
        List<TIndustry> tIndustries = tIndustryMapper.selectList(new QueryWrapper<TIndustry>().lambda().eq(TIndustry::getName, tIndustry.getName()));
        if (tIndustries.size() > 0) {
            throw new RuntimeException("行业名称已存在");
        }
        return tIndustryMapper.insert(tIndustry);
    }

    /**
     * 修改行业表
     * 
     * @param tIndustry 行业表
     * @return 结果
     */
    @Override
    public int updateTIndustry(TIndustry tIndustry)
    {
        return tIndustryMapper.updateTIndustry(tIndustry);
    }

    /**
     * 批量删除行业表
     * 
     * @param ids 需要删除的行业表主键
     * @return 结果
     */
    @Override
    public int deleteTIndustryByIds(Long[] ids)
    {
        return tIndustryMapper.deleteTIndustryByIds(ids);
    }

    /**
     * 删除行业表信息
     * 
     * @param id 行业表主键
     * @return 结果
     */
    @Override
    public int deleteTIndustryById(Long id)
    {
        return tIndustryMapper.deleteTIndustryById(id);
    }
}
